package com.microlecture.utils;
import com.microlecture.entity.UserEntity;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 登录工具类
 * Created by ZSMOME on 2018/3/31.
 */
public class LoginUtils {

    /**
     * 用户是不是失效
     * @return
     */
    public static boolean isSessionInvalid() {
        UserEntity userEntity = (UserEntity) SecurityUtils.getSubject().getPrincipal();
        if (userEntity == null) {
            return true;
        }
        return false;
    }

    /**
     * 返回当前用户信息
     * @return
     */
    public static UserEntity getCurrentUserInfo() {
        return (UserEntity) SecurityUtils.getSubject().getPrincipal();
    }


}
